package com.mallcai.bigdata.ladon.dpl.mapper.system;

import com.mallcai.bigdata.ladon.dpl.entity.system.RoleRlResource;
import com.mallcai.bigdata.ladon.dpl.mapper.system.provider.RoleRlResourceSqlProvider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author gst
 * @date 2019-12-30 20:36
 */
@Repository
public interface RoleRlResourceMapper {

    @InsertProvider(type = RoleRlResourceSqlProvider.class, method = "insert")
    public int insert(RoleRlResource rrr);

    @UpdateProvider(type = RoleRlResourceSqlProvider.class, method = "update")
    public int update(RoleRlResource rrr);

    @UpdateProvider(type = RoleRlResourceSqlProvider.class, method = "delete")
    public int delete(RoleRlResource rrr);

    @Delete({
            "DELETE FROM " + RoleRlResourceSqlProvider.TB_ROLE_RL_RESOURCE + " WHERE archive = 0 AND role_id = #{roleId}"
    })
    public int deleteByRoleId(@Param("roleId") Long roleId);

    @SelectProvider(type = RoleRlResourceSqlProvider.class, method = "getByRoleIds")
    public List<RoleRlResource> getByRoleIds(@Param("roleIds") List<Long> roleIds);

    @SelectProvider(type = RoleRlResourceSqlProvider.class, method = "getOptResourceInfo")
    public List<RoleRlResource> getOptResourceInfo(@Param("userId") Long userId);
}
